<template>
  <div>
    <h1>vuex</h1>
    <div>{{$store.state.count}}</div>
    <p>{{$store.state.userInfo.name}}</p>
    <button @click="fn">点击</button>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  created(){
   console.log( this.$store.state.count);
  },
  methods:{
    fn(){
      this.$store.commit('modName','小明')
    }
  },
  computed:{
    ...mapState(['userInfo'])
  }
}
</script>